home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 4
/
FM Towns Free Software Collection 4 - Disc 1.iso
/
toda
/
src
/
movplay.c
< prev
next >
Wrap
Text File
|
1991-10-18
|
24KB
|
974 lines
/* VIDEO PLAY
Hiroshi TODA
1991 2/11
*/
#include <stdio.h>
#include <stdlib.h>
#include <egb.h>
#include <mos.h>
#include <snd.h>
#include "video.h"
#define C_WT 0x7fff /* カーソル color */
#define C_PL 24311 /* 初期プレーン color */
#define C_FL 0x303030 /* files back color */
#define C_COLOR 15 /* Command color palette */
#define W_COLOR 8 /* Window color palette */
#define B_COLOR 7 /* Back color palette */
#define E_COLOR 10 /* ERROR color palette */
#define P_COLOR 12 /* PLAY color palette */
int sw = 0, cx = 0, cy = 0; /* MOUSE data */
char para[256]; /* PARAM */
char gwork[1024]; /* 自家製 graphic work */
char swork[16384]; /* SND work */
char ework[1536]; /* EGB work */
char mwork[4096]; /* MOUSE work */
void display_ini()
{
DWORD(para+0) = 0x1b80; /* console ini */
console(gwork,para);
EGB_init(ework,1536); /* graph ini */
EGB_resolution(ework,0,10); /* モード10,3合成 */
EGB_resolution(ework,1,3);
EGB_writePage(ework,0); /* mode10設定 */
EGB_displayStart(ework,2,2,2);
EGB_displayStart(ework,3,320,240);
EGB_color(ework,0,C_PL); /* clear paint */
EGB_color(ework,2,C_PL);
EGB_paintMode(ework,0x22);
EGB_writeMode(ework,0);
EGB_penSize(ework,1);
WORD(para+0) = 0;
WORD(para+2) = 0;
WORD(para+4) = 319;
WORD(para+6) = 239;
EGB_rectangle(ework,para);
EGB_writePage(ework,1); /* mode3に書き込み */
EGB_displayPage(ework,1,3); /* mode3が前側 */
MOS_start(mwork,4096); /* mouse ini */
MOS_resolution(0,10);
MOS_resolution(1,3);
MOS_writePage(1);
MOS_horizon(0,639);
MOS_vertical(0,479);
MOS_disp(0);
MOS_setpos( 320, 240 );
DWORD(para+0) = 0; /* key ini */
keyin(gwork,para);
DWORD(para+0) = 0x0200; /* ASCII code */
DWORD(para+4) = 0;
DWORD(para+8) = 0;
DWORD(para+12) = 0;
keyin(gwork,para);
DWORD(para+0) = 1; /* files背景色 */
DWORD(para+4) = 7;
DWORD(para+8) = C_FL;
EGB_palette(ework,1,para);
}
void ini()
{
SND_init(swork);
SND_elevol_init();
SND_elevol_mute(0x03);
display_ini();
}
void end()
{
MOS_end();
EGB_init(ework,1536);
DWORD(para+0) = 0;
SND_elevol_mute(0);
SND_end();
keyin(gwork,para);
}
windget()
{
EGB_writePage(ework,1); /* mode3に書き込み */
EGB_clearScreen(ework);
EGB_textZoom(ework,0,8,16);
EGB_textZoom(ework,1,16,16);
EGB_writeMode(ework,0);
EGB_color(ework,0,W_COLOR); /* Window paint */
EGB_color(ework,2,W_COLOR);
EGB_paintMode(ework,0x22);
EGB_writeMode(ework,0);
WORD(para+0) = 0;
WORD(para+2) = 448;
WORD(para+4) = 639;
WORD(para+6) = 479;
EGB_rectangle(ework,para);
EGB_color(ework,0,C_COLOR);
EGB_displayPage(ework,1,3); /* mode3が前側 */
return 0;
}
windput()
{
EGB_clearScreen(ework);
EGB_displayPage(ework,1,1); /* mode10のみ表示 */
return 0;
}
mouse(mmd)
int mmd;
{
int s, x, y;
do{
MOS_rdpos(&sw,&cx,&cy);
}while( sw == 0 );
if( mmd == 0 ){
do{
MOS_rdpos(&s,&x,&y);
}while( s );
}
return 0;
}
itochar(n,count,p) /* n --> char p[count] */
int n,count;
char *p;
{
char dsp[] = "0123456789ABCDEF";
switch( count ){
case 8: *p++ = dsp[ n/10000000 ];
n = n % 10000000;
case 7: *p++ = dsp[ n/1000000 ];
n = n % 1000000;
case 6: *p++ = dsp[ n/100000 ];
n = n % 100000;
case 5: *p++ = dsp[ n/10000 ];
n = n % 10000;
case 4: *p++ = dsp[ n/1000 ];
n = n % 1000;
case 3: *p++ = dsp[ n/100 ];
n = n % 100;
case 2: *p++ = dsp[ n/10 ];
n = n % 10;
case 1: *p++ = dsp[ n ];
*p = (char)0;
}
return 0;
}
ginput( p, x, y, max ) /* キーボード入力 */
char *p;
int x,y,max;
{
int i,a;
MOS_disp(0);
EGB_paintMode(ework,0x22);
EGB_writeMode(ework,0);
EGB_color(ework,0,C_COLOR);
BYTE( p + max ) = 0;
gin01: for ( i=0 ; i<=max ; i++ ){
if( BYTE( p + i ) == 0 )break;
}
gprint( p, x, y );
EGB_color(ework,0,W_COLOR); /* 2 Brock del */
EGB_color(ework,2,W_COLOR);
WORD(para+0) = x + i*8;
WORD(para+2) = y - 15;
WORD(para+4) = x + i*8 + 15;
WORD(para+6) = y;
EGB_rectangle(ework,para);
EGB_color(ework,0,C_COLOR);
gprint( "_", x+i*8, y+1 );
gin02: a = keyinput();
if( a == -1 )return 0;
if( (a == 0x08) && (i > 0) ){
BYTE( p + i -1 ) = 0;
goto gin01;
}
if( a == 0x0d )return 0;
if( (a < 0x20) || (a == 0x7f) )goto gin02;
if( i < max ){
WORD( p + i ) = a;
EGB_color(ework,0,W_COLOR);
gprint( "_", x+i*8, y+1 );
EGB_color(ework,0,C_COLOR);
}
goto gin01;
}
keyinput() /* 1文字input */
{
char p[32], q[32];
MOS_disp(1);
DWORD(p+0) = 0x0901;
do{
keyin(q,p);
MOS_rdpos(&sw,&cx,&cy); /* mouse sw1 -> back */
if( sw & 1 )return -1;
}while( BYTE(q + 13) == 0xff ); /* DH = 0xff->(no input) */
MOS_disp(0);
return BYTE(q + 12); /* DL = key input */
}
gprint( p, x, y ) /* LINE PRINT */
char *p;
int x,y;
{
int i;
char dsp[86];
EGB_writePage(ework,1); /* mode3に書き込み */
WORD(dsp+0) = x;
WORD(dsp+2) = y;
for ( i=0 ; i<80 ; i++ ){
dsp[ i + 6 ] = (char)( BYTE( p + i ) );
if( dsp[ i + 6 ] == (char)0 )break;
}
WORD(dsp+4) = i;
EGB_writeMode(ework,0);
EGB_sjisString(ework,dsp);
return 0;
}
gprint2( p, x, y ) /* LINE PRINT ( OVER WRITE ) */
char *p;
int x,y;
{
int i;
char dsp[70];
EGB_writePage(ework,1); /* mode3に書き込み */
for ( i=0 ; i<64 ; i++ ){
dsp[ i + 6 ] = (char)( BYTE( p + i ) );
if( dsp[ i + 6 ] == (char)0 )break;
}
EGB_paintMode(ework,0x22);
EGB_writeMode(ework,0);
EGB_color(ework,0,W_COLOR); /* Brock del */
EGB_color(ework,2,W_COLOR);
WORD(para+0) = x;
WORD(para+2) = y - 15;
WORD(para+4) = x + i*8;
WORD(para+6) = y;
EGB_rectangle(ework,para);
EGB_color(ework,0,C_COLOR);
WORD(dsp+0) = x;
WORD(dsp+2) = y;
WORD(dsp+4) = i;
EGB_sjisString(ework,dsp);
return 0;
}
/* file display */
look_files( path, fullname )
char path[65], fullname[80];
{
int i,j,k,n,m;
char out[64], dta[64], name[48][14];
int point[][2] = {
{ 8, 76 },
{ 232, 76 },
{ 456, 76 },
{ 8,100 },
{ 232,100 },
{ 456,100 },
{ 8,124 },
{ 232,124 },
{ 456,124 },
{ 8,148 },
{ 232,148 },
{ 456,148 },
{ 8,172 },
{ 232,172 },
{ 456,172 },
{ 8,196 },
{ 232,196 },
{ 456,196 },
{ 8,220 },
{ 232,220 },
{ 456,220 },
{ 8,244 },
{ 232,244 },
{ 456,244 },
{ 8,268 },
{ 232,268 },
{ 456,268 },
{ 8,292 },
{ 232,292 },
{ 456,292 },
{ 8,316 },
{ 232,316 },
{ 456,316 },
{ 8,340 },
{ 232,340 },
{ 456,340 },
{ 8,364 },
{ 232,364 },
{ 456,364 },
{ 8,388 },
{ 232,388 },
{ 456,388 },
{ 8,412 },
{ 232,412 },
{ 456,412 },
{ 8,436 },
{ 232,436 },
{ 456,436 }
};
char dsp[] = "<<FILES>> NEXT EXIT";
char para2[64], para3[64],path2[64]; /* path2保存用 */
windget();
for( i=0 ; i<64 ; i++ )path2[i] = path[i]; /* 保存 */
file0A: if( path[0] == (char)0 ){
path[0] = '\\';
path[1] = (char)0;
}
if( path[0] != (char)0 ){
k = 0;
for( i = 0 ; i<59 ; i++ ){
if( path[i] == (char)0 )break;
if( (path[i] == '*') || (path[i] == '.') ){
k = 1;
break;
}
}
if( k )for( i = 0 ; i<64 ; i++ )path[i] = path2[i];
for( i = 0 ; i<59 ; i++ ){
para3[i] = path[i];
if( para3[i] == (char)0 )break;
}
if( k == 0 ){
if( para3[i-1] != '\\' ){
path[i] = '\\';
path[i+1] = (char)0;
para3[i++] = '\\';
}
para3[i++] = '*';
para3[i++] = '.';
para3[i++] = '*';
para3[i++] = (char)0;
}
}
EGB_color(ework,0,B_COLOR);
EGB_color(ework,2,B_COLOR);
EGB_paintMode(ework,0x22);
EGB_writeMode(ework,0);
WORD(para+0) = 0;
WORD(para+2) = 0;
WORD(para+4) = 639;
WORD(para+6) = 479;
EGB_rectangle(ework,para);
EGB_color(ework,0,W_COLOR);
EGB_color(ework,2,W_COLOR);
EGB_paintMode(ework,0x22);
EGB_writeMode(ework,0);
WORD(para+0) = 0;
WORD(para+2) = 0;
WORD(para+4) = 639;
WORD(para+6) = 47;
EGB_rectangle(ework,para);
WORD(para+0) = 0;
WORD(para+2) = 448;
WORD(para+4) = 639;
WORD(para+6) = 479;
EGB_rectangle(ework,para);
EGB_color(ework,0,C_COLOR);
gprint( dsp, 0, 463 );
file00: n = 0;
DWORD(para2+0) = ( unsigned int )para3;
DWORD(para2+4) = ( unsigned int )out;
DWORD(para2+8) = ( unsigned int )dta;
DWORD(para2+12) = 0x30;
DWORD(para2+16) = 0;
k = files( gwork, para2 );
if( k != 0 ){
gprint( "File Not found", 8, 32 );
goto file03;
}
gprint( "<<PATH NAME>>", 8, 32 ); /* path name disp */
gprint( path, 120, 32 );
gprint( out, point[0][0], point[0][1] ); /* first disp */
itochar( DWORD( dta + 0x1a ), 8, out + 16 );
if( dta[0x15] != 0x10 ){ /* file name */
gprint( out + 16, point[0][0] + 112, point[0][1] );
}
if( dta[0x15] == 0x10 ){ /* dir */
gprint( " <<DIR>>", point[0][0] + 112, point[0][1] );
}
for( i=0 ; i<13 ; i++ )name[0][i] = dta[ i + 0x1e ]; /* f-name */
name[0][13] = dta[ 0x15 ]; /* attr. */
n++;
file01: DWORD(para2+0) = ( unsigned int )para3;
DWORD(para2+4) = ( unsigned int )out;
DWORD(para2+8) = ( unsigned int )dta;
DWORD(para2+12) = 0x30;
DWORD(para2+16) = 1;
k = files( gwork, para2 );
if( k != 0 )goto file02;
gprint( out, point[n][0], point[n][1] );
itochar( DWORD( dta + 0x1a ), 8, out + 16 );
if( dta[0x15] != 0x10 ){ /* file name */
gprint( out + 16, point[n][0] + 112, point[n][1] );
}
if( dta[0x15] == 0x10 ){ /* dir */
gprint( " <<DIR>>", point[n][0] + 112, point[n][1] );
}
for( i=0 ; i<13 ; i++ )name[n][i] = dta[ i + 0x1e ]; /* f-name */
name[n][13] = dta[ 0x15 ]; /* attr. */
n++;
if( n < 48 )goto file01;
file02: if( n == 0 )goto file0A;
file03: MOS_disp(1); /* command */
do{ mouse(0); }while( sw & 2 ); /* sw=2 は決定の意思なし */
MOS_disp(0);
if( (cy > 447) && (cy < 463) ){
if( cx < 72 )goto file02;
if( cx < 120 ){ /* next */
EGB_color(ework,0,B_COLOR);
EGB_color(ework,2,B_COLOR);
EGB_paintMode(ework,0x22);
EGB_writeMode(ework,0);
WORD(para+0) = 0;
WORD(para+2) = 48;
WORD(para+4) = 639;
WORD(para+6) = 447;
EGB_rectangle(ework,para);
EGB_color(ework,0,C_COLOR);
n = 0;
if( k == 0 )goto file01;
if( k != 0 )goto file00;
}
if( cx < 600 )goto file02; /* nothing */
if( cx < 640 ){ /* exit */
for( i=0 ; i<64 ; i++ ){
fullname[i] = path[i];
if( (path[i]==(char)0)||(path[i]=='*') )break;
}
fullname[i] = (char)0;
EGB_clearScreen(ework);
return 1;
}
}
for( i = 0 ; i < n ; i++ ){
if( (cx>point[i][0])
&& (cx<point[i][0]+176)
&& (cy>point[i][1]-16)
&& (cy<point[i][1])
)break;
}
if( i >= n )goto file02; /* nothing */
if( name[i][13] == (char)(0x10) ){ /* path name */
if( WORD( *(name + i) ) == 0x2e )goto file02; /* '.' */
if( WORD( *(name + i) ) == 0x2e2e ){ /* '..' */
for( j=0 ; j<59 ; j++ ){ /* 0 search */
if( path[j] == (char)0 )break;
}
if( (j>=59) || (j < 2) )goto file02; /* too long */
j = j - 2;
for( m=j ; m>=0 ; m-- ){
if( path[m] == '\\' )break;
}
if( m < 0 )goto file02;
path[m] = (char)0;
goto file0A;
}
for( j=0 ; j<59 ; j++ ){
if( path[j] == (char)0 )break;
}
if( j>=59 )goto file02;
for( m=0 ; m<13 ; m++ ){
if( j >= 59 )break;
path[ j++ ] = name[i][m];
if( name[i][m] == (char)0 )break;
}
goto file0A;
}
for( j=0 ; j<64 ; j++ ){ /* fullname=path+fname */
fullname[j] = path[j];
if( (path[j] == (char)0) || (path[j] == '*') )break;
}
for( m=0 ; m<13 ; m++ ){
fullname[j++] = name[i][m];
if( name[i][m] == (char)0 )break;
}
EGB_clearScreen(ework);
return 0;
}
/* file selector */
filename( path, fullname )
char path[65], fullname[80];
{
int i;
char dsp[] = "<<FILES>> DRIVER ( A B C D E F G H I J K L M N O P Q )";
windget();
gprint( dsp, 0, 463 );
gprint( "Input PATH NAME ? ", 0, 479 );
gprint( path, 144, 479 );
MOS_disp(1);
sw = 0;
ginput( path, 144, 479, 44 );
if( (sw & 1) && (cy>447) && (cy<463) && (cx>208) && (cx<488) ){
mouse(0);
for( i=0 ; i<17 ; i++ ){
if( cx < 228 + 16*i ){
path[0] = (char)( 'A' + i );
path[1] = ':';
path[2] = (char)0;
break;
}
}
}
if( path[0] == (char)0 ){
path[0] = '\\';
get_directory( 0, path+1 );
}
MOS_disp(0);
return look_files( path, fullname );
}
fileinput( fullname )
char fullname[80];
{
windget();
gprint( "<<FILE-NAME>>", 0, 463 );
gprint( "Input FILE NAME ? ", 0, 479 );
ginput( fullname, 144, 479, 44 );
windput();
return 0;
}
moving( namemov, wait, md )
char *namemov;
int wait, md;
{
FILE *fpl; /* FILE */
FILE *fps;
int i, j, n, temp, pcmsw, address, page, total, mode;
int rep[9][3], replv;
char *bp, *pbp[8], *p;
char path[100], pcmname[13];
int pbpsz[8], para[20], para2[5]; /* para & work */
char bbuf[153600]; /* work area for vram making */
EGB_init(ework,1536); /* graph ini */
/* file open */
if( ( fpl = fopen( namemov, "rb" ) ) == NULL )return 1;
if( fread( bbuf, 1, 256, fpl ) < 256 )goto mov10;
if( DWORD( bbuf + 0 ) != 0x32564f4d )goto mov10;
if( DWORD( bbuf + 4 ) != 16 )goto mov10;
if( DWORD( bbuf + 16) != 320 )goto mov10;
if( DWORD( bbuf + 20) != 240 )goto mov10;
page = DWORD( bbuf + 12 );
total = DWORD( bbuf + 8 );
if( (bp = (char *)malloc( total )) == 0 ){
fclose( fpl ); /* out of memory */
return 7;
}
if( fread( bp, 1, total, fpl ) < total )goto mov09;
/* graphic init */
md &= 0x01;
EGB_resolution(ework,0,10+md); /* 2画面合成 */
EGB_resolution(ework,1,10+md);
EGB_displayPage(ework,0,3);
EGB_writePage(ework,0); /* 画面0設定 */
EGB_displayStart(ework,2,2,2);
EGB_displayStart(ework,3,320,240);
EGB_writePage(ework,1); /* 画面1設定 */
EGB_displayStart(ework,2,2,2);
EGB_displayStart(ework,3,320,240);
/* pcm data load */
for( i=0 ; i<8 ; i++ ){
pbp[i] = NULL;
pbpsz[i] = 0;
if( bbuf[ 72 + 8*i ] ){
for( j=0 ; j<8 ; j++ ){
pcmname[j] = bbuf[ 72+8*i+j ];
if( pcmname[j] == (char)0 )break;
}
pcmname[j] = '.';
DWORD( pcmname+j+1 ) = 'S' + 0x100*'N' + 0x10000*'D';
make_path_name( path, namemov, pcmname );
if( ( fps = fopen( path, "rb" ) ) == NULL )goto mov01;
if( fread( bbuf+256, 1, 32, fps ) < 32 )goto mov00;
total = DWORD( bbuf + 256 + 12 );
if( (pbp[i] = (char *)malloc( total+32 )) == NULL ){
goto mov00;
}
for( j=0 ; j<32 ; j++ ){
BYTE( pbp[i]+j ) = BYTE( bbuf+256+j );
}
if( fread( pbp[i]+32, 1, total, fps ) < total ){
free( pbp );
pbp[i] = NULL;
goto mov00;
}
else pbpsz[i] = total + 32;
mov00: fclose( fps );
mov01: ;
}
else { /* pcm-nameが 0,length (dword) ならarea確保 */
pbpsz[i] = DWORD( bbuf+72+8*i+4 );
if( pbpsz[i] ){
if( (pbp[i] = (char *)malloc( pbpsz[i] )) == NULL ){
pbpsz[i] = 0;
}
}
}
}
pcmsw = 0;
for( i=0 ; i<8 ; i++ )if( pbp[i] )pcmsw = 1;
if( pcmsw ){
if( SND_pcm_mode_set( 1 ) ){
SND_pcm_sound_delete( -1 );
SND_pcm_mode_set( 1 );
}
}
p = ( (char *)para ) + 16; /* p = page head dada */
para[1] = (unsigned int)bbuf;
para[3] = wait;
address = (unsigned int)bp; mode = 0x02;
n = 0; replv = 0;
for( i=0 ; i<9 ; i++ )rep[i][0] = 0;
/* main loop */
mov02: if( n >= page ){
address = (unsigned int)bp;
n = 0;
}
para[0] = address;
para[2] = mode;
address = move32( (char *)para );
mode = mode ^ 0x03;
if( BYTE(p+20) ){ /* sound1 */
SND_key_off( BYTE(p+21) );
if( BYTE(p+23) )SND_key_on( BYTE(p+21), BYTE(p+22), BYTE(p+23) );
}
if( BYTE(p+24) ){ /* sound2 */
SND_key_off( BYTE(p+25) );
if( BYTE(p+27) )SND_key_on( BYTE(p+25), BYTE(p+26), BYTE(p+27) );
}
if( pcmsw ){ /* pcm */
if( para[12] ){
para2[0] = 0x0014; para2[1] = para[12];
para2[2] = 0x0014; para2[3] = (unsigned int)pbp[para[13]];
para2[4] = para[14];
if( pbpsz[para[13]] >= para2[4] )transmit( (char *)para2 );
}
if( BYTE(p+28) && pbp[BYTE(p+29)] ){
if( BYTE(p+28) == 1 ){
SND_pcm_play_stop( 71 );
SND_pcm_play( 71, BYTE(p+30), BYTE(p+31), pbp[BYTE(p+29)] );
}
if( BYTE(p+28) >= 2 ){
SND_pcm_play_stop( 71 );
SND_pcm_play2( 71, BYTE(p+30), BYTE(p+31), pbp[BYTE(p+29)] );
}
}
}
/* replv = 1~8 level は8まで */
temp = WORD( p+14 );
if( temp ){
if( temp < 0x8000 ){ /* repeat start */
if( rep[replv][0] != para[0] ){
replv++; /* level++ */
if( replv > 8 )replv = 8;
rep[replv][0] = para[0]; /* address */
rep[replv][1] = n - 1; /* page (-1の調整必要) */
rep[replv][2] = temp; /* 回数 */
}
}
else { /* repeat loop end */
if( rep[replv][2] ){
address = rep[replv][0]; /* address 修正 */
n = rep[replv][1]; /* page NO.修正 */
rep[replv][2]--; /* 回数 dec. */
}
else {
replv--; /* level-- */
if( replv < 0 )replv = 0;
}
}
}
n++;
MOS_rdpos(&sw,&cx,&cy); /* end check */
if( sw == 0 )goto mov02;
mov07: MOS_rdpos(&sw,&cx,&cy); /* wait loop */
if( sw & 1 ){
while( sw == 3 )MOS_rdpos(&sw,&cx,&cy);
if( sw == 2 )goto mov08;
while( sw ){
MOS_rdpos(&sw,&cx,&cy);
if( sw == 3 )break;
}
goto mov02;
}
mov08: if( sw )goto mov07;
SND_pcm_play_stop( 71 );
for( i=0 ; i<72 ; i++ )SND_key_off( i );
for( i=0 ; i<8 ; i++ )if( pbp[i] )free( pbp[i] );
free( bp );
fclose( fpl );
return 0;
mov09: free( bp );
mov10: fclose( fpl );
return 58;
}
/* fmb & pmb load return 0:non data return 1:data有り */
fmb_pmb_load( namemov )
char *namemov;
{
FILE *fp;
int i, j, k, temp;
char head[256], bank[8];
char fmbname[13], pmbname[13], path[100];
if( ( fp = fopen( namemov, "rb" ) ) == NULL )return 0;
temp = fread( head, 1, 256, fp );
fclose( fp );
if( temp < 256 )return 0;
if( DWORD( head + 0 ) != 0x32564f4d )return 0;
if( DWORD( head + 4 ) != 16 )return 0;
if( DWORD( head + 16) != 320 )return 0;
if( DWORD( head + 20) != 240 )return 0;
for( i=0 ; i<8 ; i++ ){
fmbname[i] = BYTE( head+40+i );
if( fmbname[i] == (char)0 )break;
}
if( i != 0 ){
fmbname[i] = '.';
DWORD( fmbname+i+1 ) = 'F' + 0x100*'M' + 0x10000*'B';
make_path_name( path, namemov, fmbname );
SND_fm_bank_load( path, bank );
for( k=0 ; k<6 ; k++ )SND_inst_change( k, BYTE(head+48+k) );
}
for( j=0 ; j<8 ; j++ ){
pmbname[j] = BYTE( head+56+j );
if( pmbname[j] == (char)0 )break;
}
if( j != 0 ){
pmbname[j] = '.';
DWORD( pmbname+j+1 ) = 'P' + 0x100*'M' + 0x10000*'B';
make_path_name( path, namemov, pmbname );
SND_pcm_bank_load( path, bank );
for( k=0 ; k<8 ; k++ )SND_inst_change( 64+k, BYTE(head+64+k) );
}
if( i+j )return 1;
else return 0;
}
/* path = fullname(path) + name 合成 */
make_path_name( path, fulname, name )
char path[], fulname[], name[];
{
int i, k;
for( k=0 ; k<80 ; k++ ){
path[k] = fulname[k];
if( path[k] == (char)0 )break;
}
for( i=k ; i>=0 ; i-- ){ /* path name 抽出 */
if( path[i] == '\\' || path[i] == ':' )break;
}
for( k=0 ; k<13 ; k++ ){
path[i+1+k] = name[k];
if( name[k] == (char)0 )break;
}
return 0;
}
movfile( name, namemov )
char name[], namemov[];
{
int i;
for( i=0 ; i<76 ; i++ ){
namemov[i] = name[i];
if( name[i] == '.' || name[i] == (char)0 )goto mov01;
}
return 55; /* bad file name */
mov01: if( i == 0 )return 55;
namemov[i++] = '.'; namemov[i++] = 'M'; namemov[i++] = 'O';
namemov[i++] = 'V'; namemov[i] = (char)0;
return 0;
}
error_check(number)
int number;
{
char p[16];
if( number == 0 )return 0;
MOS_disp(0);
windget();
EGB_color(ework,0,E_COLOR);
gprint( "<<ERROR>>", 0, 471 );
if( number == 7 )gprint( "out of memory", 88, 471 );
if( number == 55)gprint( "bad file name", 88, 471 );
if( number == 58)gprint( "bad data in file", 88, 471 );
if( number == 1 )gprint( perror( NULL ), 88, 471 );
if( number == 2 )gprint( perror( NULL ), 88, 471 );
/*itochar( number, 8, p );
gprint( p, 0, 471 );*/ /* check for 開発用 */
gprint( "press mouse button", 352, 471 );
EGB_color(ework,0,C_COLOR);
MOS_disp(1);
mouse(0);
MOS_disp(0);
windput();
return -1;
}
void main(ac,av)
char ac,*av[];
{
char path[80]; /* PATH NAME1 */
char fullname[100]; /* PATH + FILES NAME1 */
char namemov[80]; /* mov file name */
char dsp1[] = "<<PLAY>> FILES END";
char dsp2[] = " WAIT= MODE= FILE-NAME<< >>";
int i, j = 0, wait = 0, mode = 0, temp;
char dsp[10];
ini();
if( ac >= 2 ){
for( i=0 ; i<80 ; i++ ){
fullname[i] = ( char )( BYTE( av[1] + i ) );
if( fullname[i] == 0 )break;
}
if( ac >= 3 )if( WORD( av[2] ) == '-'+0x100*'v'
|| WORD( av[2] ) == '-'+0x100*'V'
)mode = 1;
goto main_go;
}
main00: MOS_disp(0);
windput();
windget();
gprint(dsp1,0,463);
gprint(dsp2,0,479);
EGB_color(ework,0,P_COLOR);
gprint(" PLAY",0,479); /* PLAY display */
EGB_color(ework,0,C_COLOR);
gprint2( fullname, 296, 479 );
itochar( wait, 2, dsp );
gprint2( dsp, 104, 479 );
itochar( mode, 1, dsp );
gprint2( dsp, 176, 479 );
main01: MOS_disp(1);
mouse(1);
if( (cx >= 56) && (cx < 128) && (cy >=463) ){ /* wait */
MOS_disp(0);
main0A: if( sw == 1 )wait = wait + 1;
if( sw == 2 )wait = wait - 1;
if( wait < 0 )wait = 99;
if( wait > 99 )wait = 0;
itochar( wait, 2, dsp );
gprint2( dsp, 104, 479 );
if( j == 0 ){
for( i=0 ; i<125000 ; i++ );
j = 1;
MOS_rdpos(&sw,&cx,&cy);
if( sw )goto main0A;
j = 0;
goto main01;
}
for( i=0 ; i<15000 ; i++ );
MOS_rdpos(&sw,&cx,&cy);
if( sw )goto main0A;
j = 0;
goto main01;
}
if( (cx >= 128) && (cx < 192) && (cy >=463) ){ /* mode */
MOS_disp(0);
main0B: if( sw == 1 )mode = mode + 1;
if( sw == 2 )mode = mode - 1;
if( mode < 0 )mode = 1;
if( mode > 1 )mode = 0;
itochar( mode, 1, dsp );
gprint2( dsp, 176, 479 );
if( j == 0 ){
for( i=0 ; i<125000 ; i++ );
j = 1;
MOS_rdpos(&sw,&cx,&cy);
if( sw )goto main0B;
j = 0;
goto main01;
}
for( i=0 ; i<15000 ; i++ );
MOS_rdpos(&sw,&cx,&cy);
if( sw )goto main0B;
j = 0;
goto main01;
}
mouse(0);
if( (cy < 447) || (sw != 1) )goto main01;
MOS_disp(0);
if( cy < 463 ){
if( cx < 536 )goto main01;
if( cx < 592 ){ /* files */
windput();
filename( path, fullname );
goto main00;
}
if( cx < 608 )goto main01;
if( cx < 640 ){ /* end */
windput();
end();
return;
}
goto main01;
}
if( cy < 480 ){
if( (cx < 56) && (sw == 1) ){ /* play */
windput();
main_go: if( error_check( movfile(fullname,namemov) )==0 ){
fmb_pmb_load( namemov );
temp = moving( namemov, wait, mode );
display_ini();
error_check( temp );
}
goto main00;
}
if( cx < 192 )goto main01;
if( cx < 640 ){ /* file name */
windput();
fileinput( fullname );
goto main00;
}
goto main01;
}
goto main01;
}